package com.example.oss.entity;

import lombok.Data;

@Data
public class Page {
    private Integer page = 1;
    private Integer limit = 7;
    private Integer totalSize;
    private String path;

    public Integer getFrom() {
        return getTo() - 4;
    }

    public Integer getTo() {
        if (page > getTotalPage()) return getTotalPage().intValue();
        if (page < 6) return 5;
        return page;

    }

    public Integer getTotalPage() {
        if (totalSize % limit == 0) return totalSize / limit;
        return totalSize / limit + 1;
    }

    public Integer getOffset() {
        return limit * page - limit;
    }
}
